<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
<html>
<head>
	<title>图片裁剪工具</title>
    <script type="text/javascript" src="resources/js/swfobject.js"></script>
    <script type="text/javascript" src="resources/js/fullAvatarEditor.js"></script>
</head>
<body>
	<div style="width:800px;margin: 0 auto;">
       <h1 style="text-align:center">富头像上传编辑器演示</h1>
       <div>
           <p id="swfContainer">
               	本组件需要安装Flash Player后才可使用，请从
               <a href="http://www.adobe.com/go/getflashplayer">这里</a>下载安装。
           </p>
       </div>
       <button type="button" id="upload">自定义上传按钮</button>
       <a href="upload">上传</a>
   </div>
   <script type="text/javascript">
       swfobject.addDomLoadEvent(function () {
           var swf = new fullAvatarEditor("resources/plugins/fullAvatarEditor.swf", "resources/plugins/expressInstall.swf", "swfContainer", {
                   id : "swf",
                   upload_url : "upload",
                   method : "post",
                   //src_url : "resources/img/Default.jpg",
                   src_upload : 2,
                   avatar_scale:2
               }, function (msg) {
                   switch(msg.code)
                   {
                       case 1 : alert("页面成功加载了组件！");break;
                       case 2 : alert("已成功加载图片到编辑面板。");break;
                       case 3 :
                           if(msg.type == 0)
                           {
                               alert("摄像头已准备就绪且用户已允许使用。");
                           }
                           else if(msg.type == 1)
                           {
                               alert("摄像头已准备就绪但用户未允许使用！");
                           }
                           else
                           {
                               alert("摄像头被占用！");
                           }
                       break;
                       case 5 :
                           if(msg.type == 0)
                           {
                               if(msg.content.sourceUrl)
                               {
                                   alert("原图片已成功保存至服务器，url为：\n" +　msg.content.sourceUrl);
                               }
                               alert("头像已成功保存至服务器，url为：\n" + msg.content.avatarUrls.join("\n"));
                           }
                       break;
                   }
               }
           );
           document.getElementById("upload").onclick=function(){
               swf.call("upload");
           };
       });
   </script>
</body>
</html>
